// 显示IP
(function () {
    chrome.runtime.onMessage.addListener(
        function (param, sender, sendResponse) {
            var ip = param.ip;
            toggleIp(ip);
            sendResponse();
        });
    function toggleIp(ip) {
        var panel = document.getElementById('__hostUtilsIpPanel');
        if (panel == null) {
            panel = document.createElement('div');
            panel.id = "__hostUtilsIpPanel";
            panel.innerText = ip;

            panel.style.display = "block";
            panel.style.height = "20px";
            panel.style.width = "115px";
            panel.style.backgroundColor = "#f2f2f2";
            panel.style.borderRadius = "4px";
            panel.style.zIndex = "999999999";

            panel.style.position = "fixed";
            panel.style.left = "20px";
            panel.style.bottom = "20px";

            panel.style.fontSize = "14px";
            panel.style.lineHeight = "20px";
            panel.style.color = "#373e40";
            panel.style.textAlign = "center";

            panel.style.cursor = "pointer";
            document.body.appendChild(panel);
            panel.onclick = function () {
                this.remove();
            };
        } else {
            panel.remove();
        }
    }
})();